
<html>
   <head>
      <style type="text/css">
         .sikuli-code {
            font-size: 20px;
            font-family: "Osaka-mono", Monospace;
            line-height: 1.5em;
            display:table-cell;
            white-space: pre-wrap;       /* css-3 */
            white-space: -moz-pre-wrap !important;  /* Mozilla, since 1999 */
            white-space: -pre-wrap;      /* Opera 4-6 */
            white-space: -o-pre-wrap;    /* Opera 7 */
            word-wrap: break-word;       /* Internet Explorer 5.5+ */
            width: 99%;   /* remove horizontal scroll-bar when viewing in IE7 */
         }
         .sikuli-code img {
            vertical-align: middle;
            margin: 2px;
            border: 1px solid #ccc;
            padding: 2px;
            -moz-border-radius: 5px;
            -webkit-border-radius: 5px;
            -moz-box-shadow: 1px 1px 1px gray;
            -webkit-box-shadow: 1px 1px 2px gray;
         }
         .kw {
            color: blue;
         }
         .skw {
            color: rgb(63, 127, 127);
         }

         .str {
            color: rgb(128, 0, 0);
         }

         .dig {
            color: rgb(128, 64, 0);
         }

         .cmt {
            color: rgb(200, 0, 200);
         }

         h2 {
            display: inline;
            font-weight: normal;
         }  
         
         .info {
            border-bottom: 1px solid #ddd;
            padding-bottom: 5px;
            margin-bottom: 20px;
            display: none;
         }

         a {
            color: #9D2900;
         }

         body {
            font-family: "Trebuchet MS", Arial, Sans-Serif;
         }

      </style>
   </head>
<body>
<div class="info">
<h2>WriteText.sikuli\FirstFeature.sikuli</h2> <a href="WriteText.sikuli\FirstFeature.zip">(Download this script)</a>
</div>
<pre class="sikuli-code">
<span class="cmt"># Посимвольный вывод символов
</span><span class="kw">def</span> VyvestiStrokuPosimvolno(stroka):
    dlina = len(stroka)
    i = <span class="dig">0</span>
    <span class="kw">while</span> i &lt; dlina:
        tekSimvol = stroka[i]
        paste(tekSimvol)
        <span class="skw">sleep</span>(<span class="dig">0.05</span>)
        i = i + <span class="dig">1</span>

<span class="cmt"># Паузы
</span>ShortBreak = <span class="dig">1</span>
MiddleBreak = <span class="dig">3</span>
BigBreak = <span class="dig">5</span>

step = sys.argv[<span class="dig">1</span>]

<span class="cmt"># Открытие текстового редактора
</span><span class="kw">if</span> step == <span class="str">"1"</span>:
    <span class="skw">type</span>(<span class="str">'r'</span>, KeyModifier.WIN)
    <span class="skw">type</span>(Key.DELETE)
    <span class="skw">sleep</span>(ShortBreak)
<span class="cmt">#    paste(u"notepad++ -nosession")
</span>    paste(<span class="str">u"atom"</span>)
    <span class="skw">sleep</span>(MiddleBreak)
    <span class="skw">type</span>(Key.ENTER)
    <span class="skw">sleep</span>(MiddleBreak)
    exit(<span class="dig">0</span>)
<span class="cmt"># Ввод текста
</span><span class="kw">elif</span> step == <span class="str">"2"</span>:
    <span class="cmt">#type('n', KeyModifier.CTRL)
</span>    path2file = sys.argv[<span class="dig">2</span>]
    file = open(path2file, <span class="str">'r'</span>)
    <span class="kw">while</span> True:
        line = file.readline()
        <span class="kw">if</span> <span class="kw">not</span> line:
            <span class="kw">break</span>
        stroka = unicode(line, <span class="str">'utf-8'</span>)
        VyvestiStrokuPosimvolno(stroka)
    <span class="skw">sleep</span>(BigBreak)
    exit(<span class="dig">0</span>)
<span class="cmt"># Сохранение текста
</span><span class="kw">elif</span> step == <span class="str">"3"</span>:
    path2VanessaBehavoirFeature = sys.argv[<span class="dig">2</span>]
    <span class="skw">type</span>(<span class="str">'s'</span>, KeyModifier.CTRL)
    <span class="skw">sleep</span>(<span class="dig">1</span>)
    <span class="skw">type</span>(Key.DELETE)
    <span class="skw">sleep</span>(<span class="dig">1</span>)
    paste(path2VanessaBehavoirFeature)
    exit(<span class="dig">0</span>)
<span class="kw">elif</span> step == <span class="str">"4"</span>:
    <span class="skw">type</span>(Key.ENTER)
    <span class="skw">type</span>(Key.F4, KeyModifier.ALT)
    <span class="skw">sleep</span>(BigBreak)
    exit(<span class="dig">0</span>)
</pre>
</body>
</html>
